package org.jeecg.modules.core.passdata.service.impl;

import io.swagger.annotations.ApiModelProperty;
import net.sf.saxon.expr.instruct.ForEach;
import org.jeecg.modules.core.passdata.mapper.HighwayCheckPointsMapper;
import org.jeecg.modules.core.passdata.service.HighwayCheckPointService;
import org.jeecg.modules.core.passdata.vo.RenewHighwayCheckPointState;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.net.InetAddress;
import java.util.List;

@Service
public class HighwayCheckPointServiceImpl implements HighwayCheckPointService {


    @Resource
    HighwayCheckPointsMapper highwayCheckPointsMapper;

    @Override
    public void renewHighwayCheckPointState() {

        //最近传输时间 = 检测时间
        highwayCheckPointsMapper.setRecentlyTransTime();
        //最近检测时间 = 创建日期
        highwayCheckPointsMapper.setRecentlyCheckTime();
        //最近联网时间 = 对应站点的最近联网时间 站点ping完网路状态后统一更新时间
       // highwayCheckPointsMapper.setRecentlyConnTime();






    }

    @Override
    public void renewHighwaySiteState() throws Exception{
        //获取公路站点数据集合 站点编码，站点ip
        List<RenewHighwayCheckPointState> siteList = highwayCheckPointsMapper.getAllSteIP();
        for (int i = 0; i < siteList.size(); i++) {
            //能ping通放回true 反之 false 超时时间 3000毫秒
            boolean aa =  InetAddress.getByName("192.168.1.128").isReachable(3000);
            //ping ip 如果成功则更新 检测点的最近联网时间
            if(aa){
                highwayCheckPointsMapper.setRecentlyConnTime(siteList.get(i));
            }
        }


    }


}
